#pragma warning(disable: 4005)

#include "Win32FileSystem.h"
#include "Win32Platform.h"
#include "Win32XmlHelpers.h"

#include "NeroCore\NFile.h"
#include "NeroEngine\NUtility.h"
#include "NeroGame\NXmlParseHelper.h"
#include "NeroGame\NXmlParseMaster.h"
#include "NeroCore\NMemoryManager.h"

#pragma comment(lib,"SimpleINI.lib")

using namespace System;

Win32FileSystem::Win32FileSystem()
	:NFileSystem()
{
}

Win32FileSystem::~Win32FileSystem(void)
{
}

void Win32FileSystem::Initialize()
{
}

void Win32FileSystem::Load(const char* fileName)
{
	std::vector<std::string> elems = Engine::split(std::string(fileName), '.');
	
	if(elems[elems.size() - 1] == "xml")
	{
		LoadXml(fileName);
	}
}

void Win32FileSystem::LoadXml(const char*  fileName)
{
	static bool addCustumParser = true;
	if(addCustumParser)
	{
		MY_NEW(Memory::HID_Engine,"XmlHelper") NXML::NXmlAnimationHelper(NXML::NXmlParseMaster::GetInstance());
		MY_NEW(Memory::HID_Engine,"XmlHelper") NXML::NXmlTextureHelper(NXML::NXmlParseMaster::GetInstance());
		MY_NEW(Memory::HID_Engine,"XmlHelper") NXML::NXmlMaterialHelper(NXML::NXmlParseMaster::GetInstance());
		MY_NEW(Memory::HID_Engine,"XmlHelper") NXML::NXmlShaderHelper(NXML::NXmlParseMaster::GetInstance());
		MY_NEW(Memory::HID_Engine,"XmlHelper") NXML::NXmlModelHelper(NXML::NXmlParseMaster::GetInstance());
		MY_NEW(Memory::HID_Engine,"XmlHelper") NXML::NXmlPlatformHelper(NXML::NXmlParseMaster::GetInstance());
		addCustumParser = false;
	}
	NXML::NXmlParseMaster::GetInstance()->ParseXMl(fileName);
}